package o;

import android.text.TextUtils;
import java.util.Locale;

public class efz extends egv {
    private boolean ᐝ = false;

    public boolean ˎ() {
        return ॱˎ() && !ˊ();
    }

    public boolean ˊ() {
        return !this.ᐝ;
    }

    public void ॱ() {
        if (ˎ()) {
            Logger.ˏ("AppRestrictionsManager", "syncIfNeeded: sync to settings db");
            ॱ(ˌ());
            ˊˋ();
        }
    }

    public void ˊ(String str, boolean z) {
        if (ॱˎ()) {
            ॱ(str);
            if (!ˊ()) {
                ˊˋ();
            }
        } else {
            ˏ(str);
            this.ᐝ = true;
        }
        this.ʽ = str;
        int i = this.ˏ;
        ˏ(ˋ(str));
        ˊ(this.ʽ);
        if (z || egv.ˊ(i, this.ˏ)) {
            ॱ(this.ˏ);
        }
    }

    protected void ˏ() {
        if (ˊ()) {
            this.ʽ = ˈ();
        } else {
            this.ʽ = ˌ();
        }
        ˏ(ˋ(this.ʽ));
        ˊ(this.ʽ);
    }

    public void ˋ() {
        ˉ();
        egt.ˊ(ॱˋ(), "", "com.huawei.appmarket");
        if (ॱˎ() && ˊ()) {
            ॱ(null);
            return;
        }
        ˊˋ();
        ˏ(null);
    }

    protected void ʻ() {
        Logger.ˎ("AppRestrictionsManager", String.format(Locale.ENGLISH, "reloadStatus begin: parentControlSupport:%s gradeInfo:%s mainSwitchStatus:%s hasLocalLevelInfo:%s", new Object[]{Boolean.valueOf(this.ʻ), this.ʽ, Integer.valueOf(this.ʼ), Boolean.valueOf(this.ᐝ)}));
    }

    protected boolean ᐝ() {
        return azc.ˎ().ॱ() >= 21;
    }

    protected void ॱॱ() {
        this.ˊ = true;
        Logger.ˎ("AppRestrictionsManager", String.format(Locale.ENGLISH, "onStatusInited: parentControlSupport:%s gradeInfo:%s mainSwitchStatus:%s hasLocalLevelInfo:%s", new Object[]{Boolean.valueOf(this.ʻ), this.ʽ, Integer.valueOf(this.ʼ), Boolean.valueOf(this.ᐝ)}));
        if (this.ˋ != null) {
            this.ˋ.onComplete();
            this.ˋ = null;
        }
    }

    protected void ʼ() {
        ʾ();
        this.ˊ = false;
        this.ʼ = -1;
        this.ᐝ = ˊˊ();
        this.ʽ = ˊᐝ();
        this.ˏ = ˋ(this.ʽ);
        this.ʻ = false;
    }

    protected void ʽ() {
        CharSequence charSequence = this.ʽ;
        ʽॱ();
        this.ʼ = ᐝॱ();
        if (ˊ()) {
            this.ʽ = ˈ();
        } else {
            this.ʽ = ˌ();
        }
        if (ʼॱ() == 0) {
            this.ʽ = null;
        }
        this.ˏ = ˋ(this.ʽ);
        if ((!TextUtils.equals(charSequence, this.ʽ) ? 1 : null) != null) {
            ˊ(this.ʽ);
        }
    }

    protected void ˋॱ() {
        CharSequence charSequence = this.ʽ;
        if (this.ᐝ) {
            this.ʽ = ˌ();
        } else {
            this.ʽ = null;
        }
        this.ˏ = ˋ(this.ʽ);
        if ((!TextUtils.equals(charSequence, this.ʽ) ? 1 : null) != null) {
            ˊ(this.ʽ);
        }
    }

    protected void ˎ(int i) {
        if (ॱˎ()) {
            int i2 = this.ˏ;
            ˋ(i);
            switch (i) {
                case -1:
                case 0:
                    ˉ();
                    break;
                case 1:
                    ˏ();
                    break;
            }
            if (egv.ˊ(i2, this.ˏ)) {
                ॱ(this.ˏ);
            }
            egt.ˊ(ॱˋ(), dzy.ॱ(this.ˏ), "com.huawei.parentcontrol");
            return;
        }
        Logger.e("AppRestrictionsManager", "onSettingsDBMainSwitchChange while parentControlSupport not support");
    }

    protected void ॱ(int i) {
        Logger.ˏ("AppRestrictionsManager", "onGradeIdDidChange: will reboot");
        ˋˊ();
    }

    private boolean ˊˊ() {
        return euf.ˎ().ˏ("content_restrict_status", false);
    }

    private void ˊˋ() {
        euf.ˎ().ʼ("content_restrict_status");
        ˎˎ();
        ˋˋ();
        this.ᐝ = false;
    }

    private String ˌ() {
        return euf.ˎ().ॱ("settings_grade_cache", "");
    }

    private void ˏ(String str) {
        if (!TextUtils.isEmpty(str)) {
            euf.ˎ().ˋ("content_restrict_status", true);
        }
        euf.ˎ().ˋ("settings_grade_cache", str);
    }

    private void ˎˎ() {
        euf.ˎ().ʼ("settings_grade_cache");
    }

    private void ˋˋ() {
        euf.ˎ().ʼ("password");
        euf.ˎ().ʼ("first_visit_flag");
        euf.ˎ().ʼ("secrect_iv");
        euf.ˎ().ʼ("last_input_ts");
        euf.ˎ().ʼ("retry_time");
    }

    public void ˏॱ() {
        if (ॱˊ() != -1) {
            ˏ(true);
        }
        ˋ();
        dzy.ॱ(null);
    }

    public boolean ˊॱ() {
        return euf.ˎ().ˏ("HOME_COUNTRY_CHANGED", false);
    }

    public void ˏ(boolean z) {
        euf.ˎ().ˋ("HOME_COUNTRY_CHANGED", z);
    }

    public boolean ͺ() {
        if (ॱˎ()) {
            return ʻॱ() && ˊॱ();
        } else {
            return ˊॱ();
        }
    }
}
